/**
 * Created by Administrator on 2017/3/18 0018.
 */
import React from "react";
import {Popover, Button} from "antd";
import Util from "../../util/Util";


/*导出组件*/
export default class PeopleItem extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            ischeckde: false,
            isswitch: this.props.ele.status,
            ele: this.props.ele,
            int: 1,
            status: 1
        }
        this.int = 1
        this.uid = this.props.ele.uid
    }

    componentWillMount() {
        this.setState({
            ele: this.props.ele
        });
    }

    editpeople() {
        this.props.editstaffinfo(this.state.ele.phone, this.state.ele.name, this.uid, this.state.ele.roleId);
    }

    checkischose() {
        this.setState({
            ischeckde: true
        });
        this.int = 0
    }

    checkisunchose() {
        this.setState({
            ischeckde: false
        });
        this.int = 1
    }

    checkboxchose(e) {
        let is = e.target.checked;
        if (is) {
            this.setState({
                ischeckde: true,
                int: 0
            });
            this.int = 0
        } else {
            this.setState({
                ischeckde: false,
                int: 1
            });
            this.int = 1
        }
        this.props.isallclick(this.uid);
    }

    switchchose(e) {
        this.props.forbiddenandstart(e, this.props.index, this.uid);
    }

    switchcontrol(is) {
        this.setState({
            isswitch: is
        });
    }





    render() {
        let depnamelist = this.state.ele.enterpriseDomainList

        let depname
        if (depnamelist.length == 0) {
            depname = ''
        } else {
            depname = depnamelist[0].enterpriseName
        }


        let content = (
            <div>
                {
                    depnamelist.map((item, index) => {
                      return (
                          <p>{item.enterpriseName}</p>
                      );
                    })
                }
            </div>
        );

        return (
            <tr style={{height: "40px"}}>
                {/*<th style={{border: "1px solid #ccc"}}><Checkbox*/}
                {/*style={{display: "block", float: "left", marginLeft: "12px"}}*/}
                {/*onClick={this.checkboxchose.bind(this)} checked={this.state.ischeckde} ref={'checkbox'}/></th>*/}
                <th style={{border: "1px solid #e7e7e7"}}>{this.state.ele.uid}</th>
                <th style={{border: "1px solid #e7e7e7"}}>{this.state.ele.name}</th>
                <th style={{border: "1px solid #e7e7e7", clear: "both"}}>{depname}
                    <div style={{height: "20px", marginTop:"-5px", float: "right"}}><Popover placement="bottomLeft" title={"所属公司列表"}
                                                                           content={content} trigger="click">
                        <Button >....</Button>
                    </Popover></div>
                </th>
                <th style={{border: "1px solid #e7e7e7"}}>{this.state.ele.phone}</th>
                <th style={{border: "1px solid #e7e7e7"}}>{Util.dateFormat(this.state.ele.registerDate)}</th>
                <th style={{border: "1px solid #e7e7e7"}}>{this.state.ele.status == 0 ? "禁用" : "启用"}</th>
                <th style={!Util.authorityCheck("people") ? {
                    display: 'none',
                    width: 86,
                    border: "1px solid #e7e7e7"
                } : {width: 86, border: "1px solid #e7e7e7"}}><span className=" edit_icon"
                                                                    onClick={this.editpeople.bind(this)}/></th>
                {/*<th style={!Util.authorityCheck("people") ? {display: 'none',width: 86, border: "1px solid #ccc"} :{width: 86, border: "1px solid #ccc"}}><Switch checked={this.state.isswitch}*/}
                {/*onChange={this.switchchose.bind(this)}/></th>*/}
            </tr>
        )
    }
}